﻿/*****************************************************************//**
 * @file    FITKGraphObjectLoad_G_BF.h
 * @brief   Graph object for gravity and body force.
 *
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-04-12
 *********************************************************************/

#ifndef __FITKGRAPHOBJECTLOAD_G_BF_H__
#define __FITKGRAPHOBJECTLOAD_G_BF_H__

#include "FITKGraphObjectElementLoadBase.h"

#include "FITKVTKGraphAdaptorAPI.h"

// Forward declaration
class FITKGraphActor;

namespace Comp
{
    class FITKGraphRender;
}

namespace Interface
{
    class FITKModelSet;
    class FITKBoundaryLocation;
    class FITKAbaLoadBodyForce;
    class FITKAbaLoadGravity;
    class FITKAbstractAssInstance;
}

namespace Exchange
{
    /**
     * @brief   Graph object for fixed-sized gravity and body force.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-04-12
     */
    class FITKVTKGRAPHADAPTORAPI FITKGraphObjectLoad_G_BF : public FITKGraphObjectElementLoadBase
    {
        // Regist
        FITKGraphObjectRegist(FITKGraphObjectLoad_G_BF, FITKGraphObjectElementLoadBase);
        FITKCLASS(Exchange, FITKGraphObjectLoad_G_BF);

    public:
        /**
         * @brief   Constructor.
         * @param   caseData: The case data
         * @param   bForceData: The gravity or body force data object
         * @param   stepId： The step id
         * @param   details: The load type( 1: BodyForce, 2: Gravity )[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-12
         */
        FITKGraphObjectLoad_G_BF(AbaqusData::FITKDataCase* caseData, Interface::FITKAbaLoadBodyForce* bForceData, int stepId, QVariant details = QVariant(1));

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-12
         */
        virtual ~FITKGraphObjectLoad_G_BF() = default;

        /**
         * @brief   Update the load actors by current step.[override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-29
         */
        void update(bool forceUpdate = false) override;

    private:
        /**
         * @brief   Get the value to member variables.[override]
         * @param   stepId: The step id
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-13
         */
        void getValue(int stepId) override;

        /**
         * @brief   Generate load actors with gravity or body force.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-12
         */
        void generateGraphs();

        /**
         * @brief   Insert a new point and its value to points and data.[override]
         * @param   pos: The position of point
         * @param   modelId: The model id of this point
         * @param   addToLoadPoints: Add the point to the load points data.[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-12
         */
        void insertNextPoint(double* pos, int modelId, bool addToLoadPoints = true) override;

        /**
         * @brief   Initialize the actor's visualization properties.[override]
         * @param   actor: The actor
         * @param   details: Nothing[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-12
         */
        void initActorProperties(vtkProp* actor, QVariant details = QVariant()) override;

    private:
        /**
         * @brief   The load data type( 1: BodyForce, 2: Gravity )
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-12
         */
        int m_loadType = 1;

        /**
         * @brief   The force or moment value.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-12
         */
        double m_value[3]{ 0, 0, 0 };

        /**
         * @brief   The value for glyph.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-12
         */
        double m_valueForGlyph[3]{ 0, 0, 0 };

    };

    // Type define.
    typedef FITKGraphObjectLoad_G_BF FITKGraphObjectLoadGravity;
    typedef FITKGraphObjectLoad_G_BF FITKGraphObjectLoadBodyForce;
}   // namespace Exchange

#endif // __FITKGRAPHOBJECTLOAD_G_BF_H__
